﻿<Grid x:Name="userControl" x:Class="Daytimer.Controls.SplitBorderSelector"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
		xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
		mc:Ignorable="d PresentationOptions" d:DesignHeight="23" d:DesignWidth="34"
		IsEnabledChanged="userControl_IsEnabledChanged">
	<Grid.Resources>
		<Style TargetType="Separator">
			<Setter Property="Height" Value="1" />
			<Setter Property="VerticalAlignment" Value="Stretch" />
			<Setter Property="Margin" Value="1" />
			<Setter Property="IsHitTestVisible" Value="False" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Separator">
						<Border BorderThickness="1" BorderBrush="#FFE1E1E1" />
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="DashedLine" TargetType="Line">
			<Setter Property="Stroke">
				<Setter.Value>
					<DrawingBrush TileMode="Tile" ViewportUnits="Absolute" RenderOptions.CachingHint="Cache"
							PresentationOptions:Freeze="True">
						<DrawingBrush.Viewport>
							<Rect Width="2" Height="2" />
						</DrawingBrush.Viewport>
						<DrawingBrush.Drawing>
							<DrawingGroup>
								<GeometryDrawing Brush="#FF747474">
									<GeometryDrawing.Geometry>
										<RectangleGeometry>
											<RectangleGeometry.Rect>
												<Rect X="0" Y="0" Width="1" Height="0.5" />
											</RectangleGeometry.Rect>
										</RectangleGeometry>
									</GeometryDrawing.Geometry>
								</GeometryDrawing>
								<GeometryDrawing Brush="Transparent">
									<GeometryDrawing.Geometry>
										<RectangleGeometry>
											<RectangleGeometry.Rect>
												<Rect X="1" Y="0" Width="1" Height="1" />
											</RectangleGeometry.Rect>
										</RectangleGeometry>
									</GeometryDrawing.Geometry>
								</GeometryDrawing>
							</DrawingGroup>
						</DrawingBrush.Drawing>
					</DrawingBrush>
				</Setter.Value>
			</Setter>
			<Setter Property="VerticalAlignment" Value="Bottom" />
			<Setter Property="X2" Value="1" />
			<Setter Property="Stretch" Value="Fill" />
		</Style>
		<Style x:Key="ButtonSimulation" TargetType="RadioButton">
			<Setter Property="Width" Value="Auto" />
			<Setter Property="Height" Value="24" />
			<Setter Property="HorizontalAlignment" Value="Stretch" />
			<Setter Property="VerticalAlignment" Value="Stretch" />
			<Setter Property="GroupName" Value="SplitBorderSelectorRadio" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="RadioButton">
						<Grid x:Name="grid" Background="Transparent">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="30" />
								<ColumnDefinition />
							</Grid.ColumnDefinitions>
							<Border x:Name="radioButtonBorder" BorderBrush="Transparent" BorderThickness="1"
									SnapsToDevicePixels="True" Width="19" Height="19" Margin="2,0"
									HorizontalAlignment="Left" VerticalAlignment="Center" IsHitTestVisible="False">
								<Border x:Name="middleBorder" SnapsToDevicePixels="True" BorderThickness="1"
										BorderBrush="Transparent" Background="Transparent">
									<Grid Width="13" Height="13" HorizontalAlignment="Center" VerticalAlignment="Center">
										<Line Style="{StaticResource DashedLine}" />
										<Line Style="{StaticResource DashedLine}" VerticalAlignment="Center" />
										<Line Style="{StaticResource DashedLine}" VerticalAlignment="Top" />
										<Line Style="{StaticResource DashedLine}" HorizontalAlignment="Left"
												VerticalAlignment="Stretch" X2="0" Y2="1" />
										<Line Style="{StaticResource DashedLine}" HorizontalAlignment="Center"
												VerticalAlignment="Stretch" X2="0" Y2="1" />
										<Line Style="{StaticResource DashedLine}" HorizontalAlignment="Right"
												VerticalAlignment="Stretch" X2="0" Y2="1" />
										<Border x:Name="innerBorder" BorderThickness="{TemplateBinding BorderThickness}"
												BorderBrush="#FF747474" SnapsToDevicePixels="True" />
									</Grid>
								</Border>
							</Border>
							<ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Left"
									VerticalAlignment="Center" Grid.Column="1" RecognizesAccessKey="True"
									Margin="0,0,6,0" />
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="Background" TargetName="grid"
										Value="{DynamicResource ButtonMouseOverBackground}" />
							</Trigger>
							<Trigger Property="IsChecked" Value="True">
								<Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="#FF92C0E0" />
								<Setter Property="BorderBrush" TargetName="middleBorder" Value="#FFE6F2FA" />
								<Setter Property="Background" TargetName="middleBorder" Value="#FFE6F2FA" />
							</Trigger>
							<Trigger Property="IsEnabled" Value="False">
								<Setter Property="Opacity" TargetName="radioButtonBorder" Value="0.5" />
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<EventSetter Event="Click" Handler="Margin_Click" />
		</Style>
	</Grid.Resources>
	<Grid.ColumnDefinitions>
		<ColumnDefinition Width="*" />
		<ColumnDefinition Width="Auto" />
	</Grid.ColumnDefinitions>
	<Border x:Name="PART_Overlay" Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="Transparent" />
	<Button x:Name="PART_Button" Width="NaN" Height="NaN" MinWidth="0" Click="PART_Button_Click">
		<Button.Template>
			<ControlTemplate TargetType="{x:Type Button}">
				<Border x:Name="PART_Border" Background="Transparent">
					<Grid Width="13" Height="13" HorizontalAlignment="Center" VerticalAlignment="Center"
							IsHitTestVisible="False">
						<Line Style="{StaticResource DashedLine}" />
						<Line Style="{StaticResource DashedLine}" VerticalAlignment="Center" />
						<Line Style="{StaticResource DashedLine}" VerticalAlignment="Top" />
						<Line Style="{StaticResource DashedLine}" HorizontalAlignment="Left" VerticalAlignment="Stretch"
								X2="0" Y2="1" />
						<Line Style="{StaticResource DashedLine}" HorizontalAlignment="Center"
								VerticalAlignment="Stretch" X2="0" Y2="1" />
						<Line Style="{StaticResource DashedLine}" HorizontalAlignment="Right"
								VerticalAlignment="Stretch" X2="0" Y2="1" />
						<Border x:Name="PART_Selected" BorderBrush="#FF747474"
								BorderThickness="{Binding SelectedBorder, ElementName=userControl}" />
					</Grid>
				</Border>
				<ControlTemplate.Triggers>
					<Trigger Property="IsMouseOver" Value="True">
						<Setter Property="Background" TargetName="PART_Border" Value="{DynamicResource RibbonMouseOver}" />
					</Trigger>
					<Trigger Property="IsPressed" Value="True">
						<Setter Property="Background" TargetName="PART_Border" Value="{DynamicResource RibbonPressed}" />
					</Trigger>
				</ControlTemplate.Triggers>
			</ControlTemplate>
		</Button.Template>
	</Button>
	<ToggleButton x:Name="PART_ToggleButton" Grid.Column="1" Width="13"
			IsChecked="{Binding IsChecked, ElementName=userControl}" ClickMode="Press">
		<ToggleButton.Template>
			<ControlTemplate TargetType="{x:Type ToggleButton}">
				<Border x:Name="PART_Border" Background="Transparent">
					<Path x:Name="Arrow"
							Data="F1M0,0L2.667,2.66665 5.3334,0 5.3334,-1.78168 2.6667,0.88501 0,-1.78168 0,0z"
							Fill="#FF606060" HorizontalAlignment="Center" Margin="0,2,0,0" VerticalAlignment="Center"
							IsHitTestVisible="False" />
				</Border>
				<ControlTemplate.Triggers>
					<Trigger Property="IsMouseOver" Value="True">
						<Setter Property="Background" TargetName="PART_Border" Value="{DynamicResource RibbonMouseOver}" />
					</Trigger>
					<Trigger Property="IsChecked" Value="True">
						<Setter Property="Background" TargetName="PART_Border" Value="{DynamicResource RibbonChecked}" />
					</Trigger>
					<Trigger Property="IsPressed" Value="True">
						<Setter Property="Background" TargetName="PART_Border" Value="{DynamicResource RibbonPressed}" />
					</Trigger>
				</ControlTemplate.Triggers>
			</ControlTemplate>
		</ToggleButton.Template>
	</ToggleButton>
	<Popup x:Name="PART_Popup" IsOpen="{Binding IsChecked, ElementName=userControl}" HorizontalOffset="-5"
			VerticalOffset="-6" PopupAnimation="Fade" AllowsTransparency="True" SnapsToDevicePixels="True"
			StaysOpen="False">
		<Popup.Style>
			<Style TargetType="Popup">
				<Style.Triggers>
					<Trigger Property="IsOpen" Value="True">
						<Trigger.EnterActions>
							<BeginStoryboard>
								<Storyboard>
									<DoubleAnimation Storyboard.TargetProperty="VerticalOffset" From="-30" To="-6"
											Duration="0:0:0.4">
										<DoubleAnimation.EasingFunction>
											<QuarticEase />
										</DoubleAnimation.EasingFunction>
									</DoubleAnimation>
								</Storyboard>
							</BeginStoryboard>
						</Trigger.EnterActions>
					</Trigger>
				</Style.Triggers>
			</Style>
		</Popup.Style>
		<Border x:Name="OuterBorder">
			<Border.CacheMode>
				<BitmapCache />
			</Border.CacheMode>
			<Border.Effect>
				<DropShadowEffect Color="#FFBBBBBB" ShadowDepth="0" RenderingBias="Performance" Opacity="0.5" />
			</Border.Effect>
			<Border x:Name="InnerBorder" BorderBrush="#FFC6C6C6" BorderThickness="1"
					Background="{DynamicResource White}" Margin="5">
				<Border x:Name="ItemsPresenter" Margin="1">
					<ScrollViewer VerticalScrollBarVisibility="Auto">
						<StackPanel Orientation="Vertical" x:Name="body">
							<RadioButton Style="{StaticResource ButtonSimulation}" Content="_Bottom Border"
									BorderThickness="0,0,0,1" />
							<RadioButton Style="{StaticResource ButtonSimulation}" Content="To_p Border"
									BorderThickness="0,1,0,0" />
							<RadioButton Style="{StaticResource ButtonSimulation}" Content="_Left Border"
									BorderThickness="1,0,0,0" />
							<RadioButton Style="{StaticResource ButtonSimulation}" Content="_Right Border"
									BorderThickness="0,0,1,0" />
							<Separator />
							<RadioButton Style="{StaticResource ButtonSimulation}" Content="_No Border"
									BorderThickness="0" />
							<RadioButton Style="{StaticResource ButtonSimulation}" Content="Out_side Borders"
									BorderThickness="1" />
						</StackPanel>
					</ScrollViewer>
				</Border>
			</Border>
		</Border>
	</Popup>
</Grid>
